package com.irdstudio.apicenter.frame.tag.bootstrap;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.Tag;

import com.irdstudio.apicenter.frame.core.jdbc.container.DataRow;
import com.irdstudio.apicenter.frame.tag.ParentTagSupport;

/**
 * 文本标签抽象类
 * 
 * @author zs.ligm
 * @version 1.0
 * @date 2015-06-26
 */
public abstract class TAbstractText extends ParentTagSupport {

	private static final long serialVersionUID = 1L;

	/* 该字段的惟一标识，必设 */
	protected String id = null;

	/* 该字段的显示名称，可使用多语言进行处理，必设 */
	protected String label = null;

	/* 用于显示的默认值 */
	protected String defvalue = "";

	/* 用于修饰的字典名称 */
	protected String dictname = null;

	/* 对齐方式 */
	protected String align = null;

	protected Tag parent = null;

	@Override
	public int doStartTag() throws JspException {
		if (this.parent != null && this.parent instanceof TTable) {
			// 如果父标签是Table，则直接将本身加入到父标签列表中，由父标签处理
			((TTable) this.parent).addDataField((TAbstractText) this.clone());
		}
		return SKIP_BODY;
	}

	/**
	 * 渲染标签
	 */
	public abstract void renderTag(StringBuffer sb, DataRow dataRow);

	@Override
	public String getId() {
		return id;
	}

	@Override
	public void setId(String id) {
		this.id = id;
	}

	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	public String getDefvalue() {
		return defvalue;
	}

	public void setDefvalue(String defvalue) {
		this.defvalue = defvalue;
	}

	public String getDictname() {
		return dictname;
	}

	public void setDictname(String dictname) {
		this.dictname = dictname;
	}

	@Override
	public Tag getParent() {
		return parent;
	}

	@Override
	public void setParent(Tag parent) {
		this.parent = parent;
	}

	public String getAlign() {
		return align;
	}

	public void setAlign(String align) {
		this.align = align;
	}

	/**
	 * clone标签对象所调用的方式
	 */
	@Override
	abstract public Object clone();
}
